﻿@{
    ViewBag.Title = "支付二维码";
    ViewBag.PathToBtn = "/Charge/Index";
    ViewBag.TextBtn = "刷新";
    Layout = "~/Views/Shared/_Layout.cshtml";

}

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                支付二维码
            </div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-lg-12">
                        <fieldset>
                            <div class="form-group col-md-12" style="text-align: center">
                                <label id="lbMsg">请使用微信扫码二维码(请在5分钟之内完成支付)</label>
                                <div class="input-group" style="text-align:center;width: 100%" id="divAction">
                                    <img src="@Url.Action("GenerateQRCode", "Home", new { content = @ViewBag.QrCode })" alt="支付二维码" style="max-height: 300px;" />
                                </div>
                                <label id="lbMoney">本次支付金额<b style="color:red;font-size:18px;margin-left:5px;">¥@ViewBag.Money</b></label>
                            </div>
                        </fieldset>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@section javascript{
    <script type="text/javascript">
        var checkInt;
        $(function () {
            $("#ContentHeadBtn").hide();
            setTimeout(function () {
                clearInterval(checkInt);
                $("#lbMsg").html("二维码已失效，请重新操作");
                $("#divAction").html("<a class='btn btn-primary' href='@Url.Action("Index")'>重新操作</a>");
            }, 300000);
            checkInt = setInterval(function () {
                $.ajax({
                    type: 'post',
                    url: '@Url.Action("CheckPay")',
                    data: { outTradeNoEnc: '@ViewBag.OutTradeNoEnc' },
                    async: false,
                    success: function (data) {
                        if (data.Status) {
                            location.href = "@Url.Action("Success")";
                        }
                    }
                });
            }, 2000);
        });
    </script>
}